package com.example.tutorial.java.concurrent.practice.ch6;

import java.util.Timer;
import java.util.TimerTask;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * @author: cph
 * @date: 2022-4-23
 */
public class OutOfTime {
    public static void main(String[] args) throws InterruptedException {

        Timer timer = new Timer();
        timer.schedule(new ThrowTask(), 1);
        SECONDS.sleep(1);

        timer.schedule(new ThrowTask(), 1);
        SECONDS.sleep(5);

    }

    static class ThrowTask extends TimerTask {
        @Override
        public void run() {
            throw new RuntimeException();
        }
    }
}
